package com.example.safeassistan.home.adapter;

import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.safeassistan.R;
import com.example.safeassistan.UserInfoModel;
import com.example.safeassistan.home.model.CheckLogDetailModel;

import java.util.List;

public class CheckLogDetailFragmentAdapter extends BaseQuickAdapter<CheckLogDetailModel.ResultDTO.RecordsDTO,BaseViewHolder> {
    public CheckLogDetailFragmentAdapter(@Nullable List<CheckLogDetailModel.ResultDTO.RecordsDTO> data) {
        super(R.layout.item_checklogdetail_fragment, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, CheckLogDetailModel.ResultDTO.RecordsDTO item) {
        helper.addOnClickListener(R.id.tvDetail);
        TextView tvStatus=helper.getView(R.id.tvStatus);
        helper.setText(R.id.tvTitle,(helper.getPosition()+1)+"."+item.getRiskPointName());
        helper.setText(R.id.tvCheckPerson,"检查人员："+item.getRealname());
        helper.setText(R.id.tvChecktime,"检查时间："+(item.getCreateTime()==null?"":item.getCreateTime()));
        helper.setText(R.id.tvControlName,item.getItemDesc());
        helper.setText(R.id.tvCollect,item.getCollect()==null?"暂无数据采集":item.getCollect());
        helper.setText(R.id.tvStatus1,item.getNotes());

        switch (item.getItemResult()){
            case 2:
                //有隐患
                tvStatus.setText("存在隐患");
                tvStatus.setTextColor(mContext.getResources().getColor(R.color.orange));
                tvStatus.setBackgroundResource(R.drawable.stoke_orange_bg);
                helper.getView(R.id.llHiddenDanger).setVisibility(View.VISIBLE);
                helper.getView(R.id.tvStatus1).setVisibility(View.GONE);
                helper.setText(R.id.tvHiddenDangerTitle,"隐患标题："+item.getHdangerTitle());
                if (item.getHdangerLevel()!=null){
                    if (item.getHdangerLevel().equals("1")){
                        helper.setText(R.id.tvHiddendDangerLevel,"隐患等级：一般");

                    }else {
                        helper.setText(R.id.tvHiddendDangerLevel,"隐患等级：重大");
                    }
                }

                if (item.getDisposeStatus()!=null){
                    switch (item.getDisposeStatus()){
                        case "1":
                            helper.setText(R.id.tvHiddenDangerStatus,"隐患状态：待提交");
                            break;
                        case "2":
                            helper.setText(R.id.tvHiddenDangerStatus,"隐患状态：待评审");
                            break;
                        case "3":
                            helper.setText(R.id.tvHiddenDangerStatus,"隐患状态：待整改");
                            break;
                        case "4":
                            helper.setText(R.id.tvHiddenDangerStatus,"隐患状态：待验收");
                            break;
                        case "5":
                            helper.setText(R.id.tvHiddenDangerStatus,"隐患状态：已完成");
                            break;
                        case "6":
                            helper.setText(R.id.tvHiddenDangerStatus,"隐患状态：已撤销");
                            break;
                    }
                }

                break;
            case 0:
                //有隐患
                tvStatus.setText("已通过");
                tvStatus.setTextColor(mContext.getResources().getColor(R.color.green));
                tvStatus.setBackgroundResource(R.drawable.stoke_green_bg);
                helper.getView(R.id.llHiddenDanger).setVisibility(View.GONE);
                helper.getView(R.id.tvStatus1).setVisibility(View.VISIBLE);
                helper.setText(R.id.tvStatus1,"检查通过");
                break;
            case 1:
                //有隐患
                tvStatus.setText("未通过");
                tvStatus.setTextColor(mContext.getResources().getColor(R.color.red));
                tvStatus.setBackgroundResource(R.drawable.stoke_red_bg);
                helper.getView(R.id.llHiddenDanger).setVisibility(View.GONE);
                helper.getView(R.id.tvStatus1).setVisibility(View.VISIBLE);
                helper.setText(R.id.tvStatus1,"检查不通过");
                break;
            case 3:
                //有隐患
                tvStatus.setText("未涉及");
                tvStatus.setTextColor(mContext.getResources().getColor(R.color.blue_3B5BEA));
                tvStatus.setBackgroundResource(R.drawable.stoke_blue_bg);
                helper.getView(R.id.llHiddenDanger).setVisibility(View.GONE);
                helper.getView(R.id.tvStatus1).setVisibility(View.VISIBLE);
                helper.setText(R.id.tvStatus1,"未涉及");
                break;

        }
    }
}
